package br.ufrpe.bsi.pvs;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import br.ufrpe.bsi.pvs.util.Util;
import br.ufrpe.bsi.pvs.view.PvsFrame;
import br.ufrpe.bsi.pvs.view.assistant.TelaAltura;
import br.ufrpe.bsi.pvs.view.assistant.TelaPeso;
import br.ufrpe.bsi.pvs.xml.RequestReaderXML;
import br.ufrpe.bsi.pvs.xml.ResponseReaderXML;

public class Main {

	public static void main(String[] args) {
		final JFrame splash = createSplash();
		splash.setVisible(true);

		TelaAltura.INSTANCE.revalidate();
		TelaPeso.INSTANCE.revalidate();
		ResponseReaderXML.INSTANCE.read();
		RequestReaderXML.INSTANCE.read();		
		
		Util.waitSeconds(2);

		// inicia a interface
		splash.dispose();
		PvsFrame.INSTANCE.createAndShowGUI();
	}

	private static JFrame createSplash() {
		JFrame splash = new JFrame();
		splash.setMinimumSize(new Dimension(320, 400));
		splash.toFront();
		splash.setUndecorated(true);
		Icon logo = new ImageIcon(Main.class.getResource("/images/splash.png"));
		JLabel lbLogo = new JLabel(logo);
		splash.getContentPane().add(lbLogo, BorderLayout.CENTER);
		splash.setLocationRelativeTo(null);

		return splash;
	}
}
